//
//  SWModifyUserInfoReq.swift
//  ChildStory
//
//  Created by linhan on 16/8/19.
//  Copyright © 2016年 Aiya. All rights reserved.
//

import Foundation

enum SWModifyUserInfoKey:String
{
    case avatarURL = "avatarURL"
    case screenName = "screenName"
    case desc = "desc"
    case birthday = "birthday"
    case gender = "gender"
}

class SWModifyUserInfoReq: SWBaseRequest
{
    var avatarURL:String?
    var screenName:String?
    var birthday:NSDate?
    var desc:String?
    var gender:Int = 0
    
    override init()
    {
        super.init()
        api = SWRequestAPI.ModifyUserInfo
    }
    
    override var params:Any?
    {
        var param:[String:Any] = [:]
        
        if let avatarURL = avatarURL,avatarURL != ""
        {
            param["headImg"] = avatarURL
        }
        
        if let screenName = screenName,screenName != ""
        {
            param["nickName"] = screenName
        }
        
        if let desc = desc,desc != ""
        {
            param["sign"] = desc
        }
        
        if let birthday = birthday
        {
            param["birthday"] = birthday.formattedDate(withFormat: "yyyy-MM-dd")
        }
        
        let jsonString:String = JSONHelper.JSONEncode(param)
        trace("SWModifyUserInfoReq", jsonString)
        
        return ["userInfoJsonStr":jsonString]
    }
}
